from fastapi import Request, Response
from fastapi.routing import APIRoute
from afast_core.core_libs.classy_apirouter.group_router import RestInjectForAPIRouter, RestInjectForDocRouter
from infirmary_admin_src.infirmary_common.infirmary_controller import IBaseController
from afast_core.core_libs.classy_apirouter import IHookGroupBaseController
from afast_core.core_libs.classy_apirouter import get, post
from infirmary_admin_src.infirmary_smart_admin.infirmary_biz.system.datascope.controllers.list_all import \
    SystemDataScopeListController



#  tags=['测试类装饰器依赖项']

@RestInjectForAPIRouter(prefix='/dataScope')
@RestInjectForDocRouter(tags=['后台系统-数据权限'])
class AGroupAPIRouterBuilder(IHookGroupBaseController):

    async def before_request(self, curr_apiroute: APIRoute, request: Request) -> None:
        """如果需要修改请求信息，可直接重写此方法"""
        pass
        request.state.api_router_builder = self
        # 如果存在body对象的，在这里读取一下，以备后续的使用
        request.state.schema_param_body = await request.body()
        print("request.state.schema_param_body ", request.state.schema_param_body)

    async def after_request(self, request: Request, response: Response) -> None:
        """请求后的处理"""
        pass

    @get("/list", summary='部门模块-部门列表信息获取')
    def admin_dataScope_list_all(self, controller: IBaseController = SystemDataScopeListController):
        return controller.sync_response()

